/*
 * @Author: lbt666 '1319451895@qq.com'
 * @Date: 2022-07-25 13:42:39
 * @LastEditors: lbt666 1319451895@qq.com
 * @LastEditTime: 2023-07-30 14:56:23
 * @Description: 
 */
import { defineConfig, loadEnv } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';
// import vueSetupExtend from 'vite-plugin-vue-setup-extend-plus'
import vueSetupExtend from 'vite-plugin-vue-setup-extend'

// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
  // const VITE_APP_SERVER_URL: string = loadEnv(mode, process.cwd()).VITE_APP_SERVER_URL;
  return {
    base: './',
    plugins: [
      vue(),
      vueSetupExtend(),
      Components({
        resolvers: [VantResolver()],
      })
    ],
    resolve: {
      alias: { // 配置别名
        // 设置路径
        '~': path.resolve(__dirname, './'),
        // 设置别名
        '@': path.resolve(__dirname, './src'),
        '@@': path.resolve(__dirname, './src/components'),
        web3: path.resolve(__dirname, './node_modules/web3/dist/web3.min.js')
      },
      // https://cn.vitejs.dev/config/#resolve-extensions
      extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'] // 导入时想要省略的扩展名列表
    },
    server: {
      port: 80,
      host: true,
      open: true,
      proxy: {
        '/dev-api': {
          // target: 'https://api.gamekingnf.com', // http://mathew.natapp1.cc
          target: 'http://www.bblove.club', // http://mathew.natapp1.cc
          changeOrigin: true, // 允许跨域
          rewrite: (path) => path.replace(/^\/dev-api/, '')
        }
      }
    }
  }
})
